package com.visionet.waveletData.web.repository.group;

import com.visionet.waveletData.web.entity.group.RobotGroup;
import com.visionet.waveletData.web.vo.RobotVo;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by hxpeng on 2017/1/12.
 */

@Repository
public interface RobotGroupDao extends JpaRepository<RobotGroup,Long> {

    public PageImpl<RobotVo> findPageRobotFromGroup(String groupId, Pageable page);

    @Query(value = "from RobotGroup where group_id = ?1 and robot_id = ?2 and is_deleted = 0")
    public RobotGroup groupDeleteRobot(String groupId, String robotId);


    @Query(value = "from RobotGroup where group_id = ?1 and is_deleted = 0")
    public List<RobotGroup> findAllByGroupId(String groupId);

    public int findCountByGroupId(String groupId);
}
